<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .outer{
        width: 180px;
        height: 100px;
        background-color: bisque;
    }
    .inner{
        width: 80px;
        height: 50px;
        background-color:aquamarine;
    }
</style>
<body>
    <div id="app">
        <h3>冒泡</h3>
        <div class="outer" v-on:click="showInfo">
            <div class="inner" @click="showInfo"></div>
        </div><hr>

        <h3>stop阻止冒泡</h3>
        <div class="outer" v-on:click="showInfo">
            <div class="inner" @click.stop="showMsg"></div>
        </div><hr>

        <h3>self = 当event.target是它本身的时候,才会触发</h3>
        <div class="outer" v-on:click.self="showInfo">
            <div class="inner" @click="showMsg"></div>
        </div><hr>

        <h3>事件的捕获 从父到子(不写就是从子到父)</h3>
        <div class="outer" v-on:click.capture="showInfo">
            <div class="inner" @click="showMsg"></div>
        </div><hr>

        <button @click.once="showInfo">once-事件仅仅触发一次</button>
        <hr>

        <!-- <form action="http://www.baidu.com"> -->
        <form @submit.prevent>
            <input type="text" value="100">
            <!-- 解决方案一: 使用普通按钮 - 不具备提交事件 -->
            <!-- <button type="button" @click="showInfo">阻止表单默认提交事件</button> -->
            <button @click="showInfo">阻止表单默认提交事件</button>
        </form>
        
    </div>
    
    <script src="plugins/vue2.js"></script>
    <script>
        new Vue({
            el:'#app',
            data: function(){
                return{
                }
            },

            methods:{
                showInfo(){
                    console.log('showInfo:'+event.target)
                },
                showMsg(){
                    console.log('showMsg:'+event.target)
                }
            }
        });
    </script>
</body>
</html>